<?php 
namespace My\Controller;

use Utuo\BackgroundController;

class HaggleShopController extends BackgroundController {

	// 初始化
	public function _initialize() {
		$this->setControllerTitle('4S店管理');
		$this->setActionTitle(array(
				'index' => '4S店列表',
				'add' => '添加4S店',
				'modify' => '修改4S店',
		));
		$this->setActionNav(array(
				'index', 
				'add',
		));
		
		
	}

	public function indexAction() {
		$this->getLists( 0 );
	}

	public function recycleAction() {
		$this->getLists( 1 );
	}
	
	public function addAction() {
		C("TOKEN_ON", true);
		$this->display("save");
	}
	
	public function modifyAction() {
		$id = I('id', 0, "intval");
		$haggleShop = M('HaggleShop')->where("id=%d", $id)->find();
		$this->assign("haggleShop", $haggleShop);
		$this->display("save");
	}

	public function getLists($is_deleted) {
		$condition = array();
		$page = $this->getPage();
		$pagesize = $this->getPageSize();
		$feedbackLists = M('HaggleShop')->where($condition)->field('*')->limit($pagesize)->page($page)->order('id desc')->select();
		$count = M('HaggleShop')->where($condition)->count();
		$this->assign('haggleShopLists', $feedbackLists);
		$this->showPage($count, $pagesize);
		$this->display();
	}
	
}